<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>异步任务的分类——setTimeout setInterval 、绑定dom事件、回调函数、ajax、fs</p>

    <script>
        // ==============
        console.log(0);
        for(var i=1;i<5;i++){
            console.log(i);
        }
        function fn(a) {
            console.log('fn_1');
            a()
            // setTimeout(a, 0); // 唯一的异步代码
            console.log('fn_2');
        }
        fn(function() {
            console.log('fn');
        })
        console.log('over');
        // 0 1 2 3 4 fn_1 fn fn_2 over
    </script>
</body>
</html>